import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig(() => {
  return {
    base: "./",
    server: {
      base: "./",
      host: ["0.0.0.0"],
      // https: true,
      proxy: {
        "/api": {
          target: "http://61.52.247.249:20111", // 目标地址
          changeOrigin: true, // 修改请求头中的 Origin 字段
          rewrite: (path) => path.replace(/^\/api/, ""), // 重写路径，去掉 '/api' 前缀
        },
      },
    },
    plugins: [vue()],
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
    },
  };
});
